package com.seqb.common.task;

import cn.hutool.extra.mail.MailUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.seqb.common.config.RedisConfig;
import com.seqb.common.utils.RedisUtils;
import com.seqb.utils.DateUtils;
import com.seqb.utils.JsonUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.util.*;

/**
 * @author lilinshen
 * @title 东东农场定时任务
 * @description 请填写相关描述
 * @date 2020/5/6
 */
@Component
public class DongdongNongChangJob implements Job {
    private static final Logger LOGGER = LoggerFactory.getLogger(DongdongNongChangJob.class);
    public static final HttpHeaders headers = new HttpHeaders();

    static {
        List<String> cookieList = new ArrayList<>();
        cookieList.add("wq_auth_token=C5F43BA319865AC7E311BC9FE0A9E41E1B1464604A55EDF21402AA6EADBA7F94");
        headers.put("Cookie", cookieList);
    }

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private RedisUtils redisUtils;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Object taskParams = redisUtils.get("taskParams");
            if (null != taskParams) {
                JSONArray parseArray = JSON.parseArray(taskParams.toString());
                for (int i = 0; i < parseArray.size(); i++) {
                    JSONObject item = parseArray.getJSONObject(i);
                    String type = item.getString("type");
                    if ("DongdongNongChangJob".equals(type)) {
                        JSONArray value = item.getJSONArray("value");
                        for (int j = 0; j < value.size(); j++) {
                            JSONObject jsonObject = value.getJSONObject(j);
                            List<String> cookieList = new ArrayList<>();
                            cookieList.add(jsonObject.getString("key") + "=" + jsonObject.getString("value"));
                            headers.put("Cookie", cookieList);
                        }
                    }
                }
            }
            LOGGER.info("东东农场定时任务开始-----------" + DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
            //执行任务
            boolean flag = taskList();

            if (!flag) {
                LOGGER.info("东东农场定时任务，执行失败。");
            }

            //记录是否失效
            Object flagRedis = redisUtils.get(RedisConfig.COM_PREFIX + this.getClass().getSimpleName());
            if (!flag && null == flagRedis) {
                //设置一天失效时间的key，每天只发一次邮件通知
                redisUtils.set(RedisConfig.COM_PREFIX + this.getClass().getSimpleName(), true, 86400);
                //发送邮件通知东东农场任务失效
                MailUtil.send("lilinshen@cecjx.com", "东东农场定时任务", "东东农场定时任务，用户cookie失效，请及时更新用户cookie信息。", false);
            }

            LOGGER.info("东东农场定时任务结束-----------" + DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 任务列表
     */
    public boolean taskList() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=taskInitForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc";
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class);
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("任务列表：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if (!"0".equals(code)) {
                    return false;
                }
                //获取浏览任务
                JSONObject gotBrowseTaskAdInit = result.getJSONObject("gotBrowseTaskAdInit");
                Boolean f = gotBrowseTaskAdInit.getBoolean("f");
                if (!f) {
                    JSONArray userBrowseTaskAds = gotBrowseTaskAdInit.getJSONArray("userBrowseTaskAds");
                    userBrowseTaskAds.forEach(item -> {
                        String advertId = ((JSONObject) item).getString("advertId");
                        //浏览商品任务操作
                        liulanShop(advertId);
                    });
                }

                //每天签到任务操作
                JSONObject signInit = result.getJSONObject("signInit");
                f = signInit.getBoolean("f");
                if (!f) {
                    perSignIn();
                }

                //签到浏览商品任务,领取水操作
                signInLiulanShopGetWater();

                //首次浇水奖励,领取水操作
                JSONObject firstWaterInit = result.getJSONObject("firstWaterInit");
                f = firstWaterInit.getBoolean("f");
                if (!f) {
                    firstWaterGetWater();
                }

                //每天累计浇水（10）
                JSONObject totalWaterTaskInit = result.getJSONObject("totalWaterTaskInit");
                f = totalWaterTaskInit.getBoolean("f");
                Long totalWaterTaskTimes = totalWaterTaskInit.getLong("totalWaterTaskTimes");
                if (totalWaterTaskTimes >= 10 && !f) {
                    totalWaterTask();
                }

                //获取三餐的水操作
                JSONObject gotThreeMealInit = result.getJSONObject("gotThreeMealInit");
                f = gotThreeMealInit.getBoolean("f");
                if (!f) {
                    getThreeMealWater();
                }

                //农场雨水操作
                JSONObject waterRainInit = result.getJSONObject("waterRainInit");
                f = waterRainInit.getBoolean("f");
                if (!f) {
                    waterRainForFarm();
                }

                //随机领取水任务操作
                randomGetWater();
                //邀请助力结束操作
                inviteFinished();
                //浇水操作
                useWater();
                //助力自己
                helpMySelf();
                //7天领任务操作
                sevenDayTask();
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 浏览商品任务操作
     */
    public boolean liulanShop(String advertId) {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=browseAdTaskForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("advertId", advertId);
            commonMap.put("type", "0");
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("浏览商品任务操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                if ("7".equals(code)) {
                    //浏览商品任务,领取水操作
                    liulanShopGetWater(advertId);
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 浏览商品任务,领取水操作
     */
    public boolean liulanShopGetWater(String advertId) {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=browseAdTaskForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("advertId", advertId);
            commonMap.put("type", "1");
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("浏览商品任务,领取水操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 每天签到任务操作
     */
    public boolean perSignIn() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=clockInForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("type", "1");
            commonMap.put("version", "6");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("每天签到任务操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if (!"0".equals(code)) {
                    return false;
                }
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 签到浏览商品任务,领取水操作
     */
    public boolean signInLiulanShopGetWater() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=clockInInitForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("version", "6");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if (!"0".equals(code)) {
                    return false;
                }
                JSONArray venderCoupons = result.getJSONArray("venderCoupons");
                for (int i = 0; i < venderCoupons.size(); i++) {
                    JSONObject venderCoupon = venderCoupons.getJSONObject(i);
                    String id = venderCoupon.getString("id");
                    Boolean hadGot = venderCoupon.getBoolean("hadGot");
                    //是否已经领过
                    if (hadGot) {
                        continue;
                    }
                    //浏览
                    requestUrl = "https://api.m.jd.com/client.action?functionId=clockInFollowForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
                    commonMap = new HashMap<>();
                    commonMap.put("id", id);
                    commonMap.put("type", "venderCoupon");
                    commonMap.put("step", "1");
                    commonMap.put("version", "6");
                    commonMap.put("channel", "2");
                    httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
                    restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
                    //领取
                    requestUrl = "https://api.m.jd.com/client.action?functionId=clockInFollowForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc&body={body}";
                    commonMap = new HashMap<>();
                    commonMap.put("id", id);
                    commonMap.put("type", "venderCoupon");
                    commonMap.put("step", "2");
                    commonMap.put("version", "6");
                    commonMap.put("channel", "2");
                    httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
                    restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
                }
                LOGGER.info("签到浏览商品任务,领取水操作：成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 首次浇水奖励,领取水操作
     */
    public boolean firstWaterGetWater() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=firstWaterTaskForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc";
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class);
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("首次浇水奖励,领取水操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if (!"0".equals(code)) {
                    return false;
                }
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 随机领取水任务操作
     */
    public boolean randomGetWater() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=gotWaterGoalTaskForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("type", "3");
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("随机领取水任务操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 浇水操作
     */
    public boolean useWater() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=waterGoodForFarm&appid=wh5&loginType=1&loginWQBiz=ddnc";
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class);
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("浇水操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if (!"0".equals(code)) {
                    return false;
                }
                Long totalEnergy = result.getLong("totalEnergy");
                Long frequency = totalEnergy / 10;
                for (int i = 0; i < frequency; i++) {
                    restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class);
                }
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 获取三餐的水操作
     */
    public boolean getThreeMealWater() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=gotThreeMealForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("type", "0");
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("获取三餐的水操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 累计10次操作
     */
    public boolean totalWaterTask() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=totalWaterTaskForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("累计10次操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 农场雨水操作
     */
    public boolean waterRainForFarm() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action";
            HttpMethod httpMethod = HttpMethod.POST;
            MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<>();
            requestMap.add("functionId", "waterRainForFarm");
            requestMap.add("appid", "wh5");
            requestMap.add("loginType", "1");
            requestMap.add("loginWQBiz", "ddnc");
            requestMap.add("body", "{\"type\":1,\"hongBaoTimes\":13,\"version\":3}");
            HttpEntity httpEntity = new HttpEntity(requestMap, headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class);
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("农场雨水操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 邀请助力结束操作
     */
    public boolean inviteFinished() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=masterGotFinishedTaskForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("邀请助力结束操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 助力自己操作
     */
    public boolean helpMySelf() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=initForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("imageUrl", "https://wx.qlogo.cn/mmopen/vi_32/PDrcIXNB30fnmjxGYYXT8UwYJn5MZnqhNbcicfsLRx7pwnC1oticl4NpKh6dnawk22a8dxAXxmhwYnk33lEg30icw/132");
            commonMap.put("nickName", "Tonya-Yang");
            commonMap.put("shareCode", "e0d0ef9f23e749e1bdee20baf0c9cf82");
            commonMap.put("mpin", "");
            commonMap.put("version", "4");
            commonMap.put("channel", "2");
            HttpMethod httpMethod = HttpMethod.GET;
            for (int i = 0; i < 1; i++) {
                List<String> cookieList = new ArrayList<>();
                HttpHeaders headers = new HttpHeaders();
                if (i == 0) {
                    //冬妮助力我
                    cookieList.add("wq_auth_token=481E8645B797102F928FE96D201B707D235E02BA719CF626D1A215D4F5F0EDFE");
                    headers.put("Cookie", cookieList);
                }
                HttpEntity httpEntity = new HttpEntity(null, headers);
                ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
                HttpStatus status = responseEntity.getStatusCode();
                if (status.equals(HttpStatus.OK)) {
                    String entityBody = responseEntity.getBody();
                    LOGGER.info("助力自己操作：" + entityBody);
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 7天领任务操作
     */
    public boolean sevenDayTask() {
        try {
            String requestUrl = "https://api.m.jd.com/client.action?functionId=clockInForFarm&body={body}&appid=wh5&loginType=1&loginWQBiz=ddnc";
            Map<String, Object> commonMap = new HashMap<>();
            commonMap.put("type", "2");
            commonMap.put("channel", "2");
            commonMap.put("version", "7");
            HttpMethod httpMethod = HttpMethod.GET;
            Map<String, Object> paramsMap = new HashMap<>();
            HttpEntity httpEntity = new HttpEntity(JsonUtils.beanToJson(paramsMap), headers);
            ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl, httpMethod, httpEntity, String.class, JsonUtils.beanToJson(commonMap));
            HttpStatus status = responseEntity.getStatusCode();
            if (status.equals(HttpStatus.OK)) {
                String entityBody = responseEntity.getBody();
                LOGGER.info("7天领任务操作：" + entityBody);
                JSONObject result = JSON.parseObject(entityBody);
                String code = result.getString("code");
                if ("0".equals(code)) {
                    return true;
                }
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
